for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
const mqtt = require('mqtt')
const validate = require('./validate')
const configuration = require('./configuration')
module.exports = (input, callback) => {
let error = null,
output = []
validate.sourceConfiguration(input, (validatedInput, thrownError) => {
input = validatedInput
error = thrownError
})clear
clear
/** global: clear */
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.
if (!error) {
let configurationMqtt = configuration.mqtt(input)
let client = mqtt.connect(input.source.url, configurationMqtt)
let version = 0
let topic = input.params.topics
client.on('connect', () => {
client.subscribe(topic, (errorConnection) => {
if (!errorConnection) {
client.on('message', (topic, message) => {
version = message.toString()
version
})
} else {
error = errorConnection.toString()
callback(error, output)
}
client.on('message', function (topic, message) {
if (message.toString() !== 'none') {
output.push({'message': message.toString()})
client.end()
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.